package org.example.demo.config;

import org.example.demo.model.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

//统一异常处理
@ResponseBody
@ControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler
    public Result handlerException(Exception e) {  //Exception e 捕获所有异常
        return Result.fail("内部错误");  //
    }
}
